/*
 * main.c
 *
 *  Created on: Feb 17, 2013
 *      Author: justin
 */

#include "project.h"
#define pbPin 3
int main() {
	uint16_t pbVal = 0;
	typedef enum {
		up = 1, down = 2, left = 3, right = 4, action = 5

	} button;
	uint8_t buttonNew = 0, buttonOld = 6;
	while (1) {

		if (pbVal > 30 && (buttonNew != buttonOld)) {

			pbVal = 20 * readAdc(pbPin);
			if ((pbVal > 800) && (pbVal < 1300))
				buttonNew = up;

			else if ((pbVal > 1600) && (pbVal < 2200))
				buttonNew = down;

			else if ((pbVal > 3000) && (pbVal < 3500))
				buttonNew = left;

			else if ((pbVal > 3800) && (pbVal < 4200))
				buttonNew = right;

			else if ((pbVal > 4500) && (pbVal < 5000)) buttonNew = action;

			_delay_ms(2);
		}
	}
	return 0;	//should never reach here
}
